use reqwest::header::HeaderMap;
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Debug, Clone, Serialize)]
pub struct TranscodePathParams {
    pub path: String,
    pub code: String,
}

#[derive(Deserialize, Debug, Clone, Serialize)]
pub struct TranscodeParams {
    #[serde(rename = "projectName")]
    pub project_name: String,
    pub content: Vec<TranscodePathParams>,
}

pub async fn c2rust(trans_codes: &TranscodeParams) -> Result<TranscodeParams, String> {
    let headers = HeaderMap::new();
    let fetch_result = reqwest::Client::new()
        // .post("https://free.v36.cm/v1/chat/completions")
        .post("http://gpt.livstyle.cn/api/transcode/from_json_to")
        .headers(headers)
        .json(&trans_codes)
        .send()
        .await.unwrap();
    let response: TranscodeParams  = fetch_result.json().await.unwrap();
    // println!("response: {:?}", response);
    Ok(response)
}
